<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/foundation/ext/jsp/taglib.jsp"%>
<%@ include file="/foundation/ext/jsp/workspace.jsp"%>
<html>
<head>
	<title>表具类型管理</title>
	<script type="text/javascript" src="./MeterType.js"></script>
	
	<script type="text/javascript">
    var listMeterTypeUrl 	= sys.basePath + "meterAction!listMeterType.do";
    var pageSize 			= Common.config.pageSize || 15;

    //数据字典
    var DataDict = {
    	modelArray	: <ncfw:dictWrite dicttypeId="T_METER_MODEL" type="array"/>,
   		rectrlArray	: <ncfw:dictWrite dicttypeId="T_METER_RECTRL" type="array"/>
   	};

   	//本地转化
   	var LocalRenderer = {
   		model			: function (value) {
			return Common.renderer.dictRender (DataDict.modelArray, value);
   		},
   		rectrl			: function (value) {
			return Common.renderer.dictRender (DataDict.rectrlArray, value);
   		},
   		remark			: function (value, metadata, record, rowIndex, colIndex) {	//内容
			return Common.renderer.detailRender(value, cm, colIndex);
   	   	}
   	}

   	//提交查询表单
   	var onSearch = function () {
   	   	var thisForm = queryFormPanel.getForm();
   	   	if (!thisForm.isValid()) {
			return;
   	   	}
   	   	var store = dataGrid.getStore();
  	   	var baseParamsStr = Ext.util.JSON.encode(thisForm.getValues());
	   	baseParamsStr = baseParamsStr.replace(/(query\.)/g, "");
		store.baseParams = Ext.util.JSON.decode(baseParamsStr);
   	 	store.reload({params:{start: 0, limit: pagingToolbar.pageSize}});
   	};

   	//重置查询表单
   	var onResetSearch = function () {
   		var thisForm = queryFormPanel.getForm();
   		thisForm.reset();
   	}
   	
	//初始化页面信息
	function initPage () {
		onSearch();
	}
    </script>
</head>
  <body>
    <ext:ext onReady="initPage();">
	  	<ext:viewport layout="border" otherProperties="split: true" >
	  		<ext:items>
  				<ext:panel title="表具类型管理" region="center" layout="border" border="false" iconCls="icon_plugin">
  					<ext:items>
	   					<%-- 列表面板 --%>
	   					<ext:panel var="metertypeListPanel" layout="border" border="false" otherProperties="split: true" region="center"
	   						margins="3 0 0 0">
	   						<ext:items>
	   							<%-------------------------------------------------------------------------------------------------
									定义查询条件面板  
								-------------------------------------------------------------------------------------------------%>
								<ext:formPanel var="queryFormPanel" id="queryFormPanel" collapsible="true" 
									labelAlign="left" frame="true" region="north" height="42" border="false" 
									labelWidth="58" otherProperties="split: true">
									<ext:items>
										<ext:container layout="column" defaults="{width: 220, layout: 'form'}" lazyInit="true">
											<ext:items>
												<ext:container lazyInit="true" xtype="panel">
													<ext:items>
														<ext:textField id="query.name" fieldLabel="表具型号" width="120">
														</ext:textField>
													</ext:items>
												</ext:container>
												<ext:container lazyInit="true" xtype="panel">
													<ext:items>
														<ext:comboBox fieldLabel="集中器规格" name="query.modelCombo"
															displayField="text" mode="local" triggerAction="all"
															selectOnFocus="true" forceSelection="true" width="120"
															valueField="value" value="" editable="false" hiddenName="query.model"
															store="new Ext.data.SimpleStore({
																fields : ['value', 'text'],
																data : Common.config.nullArray.concat(DataDict.modelArray)
															})">
														</ext:comboBox>
													</ext:items>
												</ext:container>
												<ext:container lazyInit="true" xtype="panel">
													<ext:items>
														<ext:comboBox fieldLabel="远程可控" name="query.rectrlCombo"
															displayField="text" mode="local" triggerAction="all"
															selectOnFocus="true" forceSelection="true" width="120"
															valueField="value" value="" editable="false" hiddenName="query.rectrl"
															store="new Ext.data.SimpleStore({
																fields : ['value', 'text'],
																data : Common.config.nullArray.concat(DataDict.rectrlArray)
															})">
														</ext:comboBox>
													</ext:items>
												</ext:container>
												<ext:container layout="table" otherProperties="columnWidth: 1.0" lazyInit="true"
												defaults="{layout: 'form', border:false, columnWidth: 1.0}">
												<ext:items>
													<ext:button text="查询" iconCls="icon_search" style="margin-right:20px;" 
														handler="onSearch" otherProperties="minWidth: Common.config.buttonWidth.defaultButton">
													</ext:button>
												</ext:items>
											</ext:container>
											</ext:items>
										</ext:container>
										
									</ext:items>
								</ext:formPanel>
	   							<%-------------------------------------------------------------------------------------------------
									定义数据列表  
								-------------------------------------------------------------------------------------------------%>
								<ext:gridPanel var="dataGrid" id="dataGrid" region="center" iconCls="icon_grid" 
									border="true" otherProperties="split: true" iconCls="icon_grid" selModel="sm" loadMask="true"
									viewConfig="{forceFit: true}" autoExpandColumn="remarkCM">
									<ext:tbar>
										<ext:toolbarSeparator></ext:toolbarSeparator>
										<ext:toolbarButton id="addBtn" text="新增" iconCls="icon_add" handler="MeterType.onAdd"
											otherProperties="minWidth: Common.config.buttonWidth.minButton">
										</ext:toolbarButton>
										<ext:toolbarButton id="updateBtn" text="修改" iconCls="icon_edit" handler="MeterType.onUpdate"
											otherProperties="minWidth: Common.config.buttonWidth.minButton">
										</ext:toolbarButton>
										<ext:toolbarButton id="deleteBtn" text="删除" iconCls="icon_delete" handler="MeterType.onDelete"
											otherProperties="minWidth: Common.config.buttonWidth.minButton">
										</ext:toolbarButton>
									</ext:tbar>
									<%-- 定义数据源--%>
									<ext:store var="dataStore" remoteSort="true" sortInfo="{field: 'name', direction: 'ASC'}"
										otherProperties="url: listMeterTypeUrl" >
										<ext:jsonReader root="result" totalProperty="totalCount"
											record="Ext.data.Record.create([
												{name : 'typeid', type : 'string', mapping: 'typeid'},
												{name : 'protoclid', type : 'string', mapping: 'protoclid'},
												{name : 'name', type : 'string', mapping: 'name'},
												{name : 'maker', type : 'string', mapping: 'maker'},
												{name : 'model', type : 'string', mapping: 'model'},
												{name : 'rectrl', type : 'string', mapping: 'rectrl'},
												{name : 'remark', type : 'string', mapping: 'remark'}
											])">
										</ext:jsonReader>
									</ext:store>
									<%-- 定义列表的列头--%>
									<ext:columnModel id="cm" var="cm">
										<ext:rowNumberer></ext:rowNumberer>										
										<ext:checkboxSelectionModel var="sm"></ext:checkboxSelectionModel>,
										{header : '表具型号', width: 100, dataIndex: 'name'},
										{header : '厂家名称', width: 200, dataIndex: 'maker'},
										{header : '表具规格', width: 100, dataIndex: 'model', renderer: LocalRenderer.model}, 
										{header : '远程可控', width: 66, dataIndex: 'rectrl', renderer: LocalRenderer.rectrl},
										{header : '备注', width: 260, dataIndex: 'remark', id: 'remarkCM', renderer: LocalRenderer.remark}
									</ext:columnModel>
									<%-- 定义列表的分页工具栏--%>
									<ext:pagingToolbar key="bbar" displayInfo="true"
										store="dataStore" var="pagingToolbar" otherProperties="pageSize: pageSize">
										<ext:plugins>new Ext.ux.Page.pageSize({beforeText : '显示', afterText : '条' })</ext:plugins>
									</ext:pagingToolbar>
								</ext:gridPanel>
	   						</ext:items>
	   					</ext:panel>
   					</ext:items>
   				</ext:panel>
	  			</ext:items>
	  	</ext:viewport>
    </ext:ext>
  </body>
  
</html>
